#include<Arduino.h>
#include<ESP8266WiFi.h>
#include<ESP8266HTTPClient.h>

void setup() {
    const char SSID[] = "GA_family";
    const char PASSWD[] = "#1qaz2wsx";

    Serial.begin(115200); 
    Serial.printf("start connect to %s\n", SSID);
    WiFi.mode(WIFI_STA);
    WiFi.begin(SSID, PASSWD);
    while (WiFi.status() != WL_CONNECTED) {
        Serial.printf("connect not ready yet (status: %d), waiting...\n", WiFi.status());
        delay(500);
    }
    Serial.printf("connected, IP: (%s)\n", WiFi.localIP().toString().c_str());
}

void loop() {
    const String request_url = "http://192.168.3.105:8090/config/8266/0001";
    WiFiClient wifi_client;
    HTTPClient http_client;
    Serial.printf("requesting [%s] ...\n", request_url.c_str());
    http_client.setTimeout(1000);
    http_client.begin(wifi_client, request_url);
    int retCode = http_client.GET();
    Serial.printf("ret code: %d\n", retCode);
    if (retCode > 0) {
        if (retCode == HTTP_CODE_OK) {
            String resp = http_client.getString();
            Serial.print("resp: ");
            Serial.println(resp);
        }
    } else {
        Serial.printf("http failed, cause : %s\n", http_client.errorToString(retCode).c_str());
    }
    http_client.end();
    delay(2000);
}